package com.haoan.index.controller;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import com.haoan.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.haoan.common.annotation.Log;
import com.haoan.common.core.controller.BaseController;
import com.haoan.common.core.domain.AjaxResult;
import com.haoan.common.enums.BusinessType;
import com.haoan.index.domain.LcNews;
import com.haoan.index.service.LcNewsService;
import com.haoan.common.utils.poi.ExcelUtil;
import com.haoan.common.core.page.TableDataInfo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 新闻中心Controller
 * 
 * @author autoGen
 * @date 2025-03-19
 */
@Api(value="新闻中心",tags = "新闻中心")
@RestController
@Anonymous
@RequestMapping("/index/lcNews")
public class LcNewsController extends BaseController
{
    @Resource
    private LcNewsService lcNewsService;

    /**
     * 查询新闻中心列表
     */
    @ApiOperation("查询新闻中心列表")
    @PreAuthorize("@ss.hasPermi('index:lcNews:list')")
    @GetMapping("/list")
    public TableDataInfo list(LcNews lcNews)
    {
        startPage();
        List<LcNews> list = lcNewsService.selectLcNewsList(lcNews);
        return getDataTable(list);
    }

    /**
     * 导出新闻中心列表
     */
    @ApiOperation("导出新闻中心列表")
    @PreAuthorize("@ss.hasPermi('index:lcNews:export')")
    @Log(title = "新闻中心", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LcNews lcNews)
    {
        List<LcNews> list = lcNewsService.selectLcNewsList(lcNews);
        ExcelUtil<LcNews> util = new ExcelUtil<LcNews>(LcNews.class);
        util.exportExcel(response, list, "新闻中心数据");
    }

    /**
     * 获取新闻中心详细信息
     */
    @ApiOperation("获取新闻中心详细信息")
    @PreAuthorize("@ss.hasPermi('index:lcNews:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(lcNewsService.selectLcNewsById(id));
    }

    /**
     * 新增新闻中心
     */
    @ApiOperation("新增新闻中心")
    @PreAuthorize("@ss.hasPermi('index:lcNews:add')")
    @Log(title = "新闻中心", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LcNews lcNews)
    {
        return toAjax(lcNewsService.insertLcNews(lcNews));
    }

    /**
     * 修改新闻中心
     */
    @ApiOperation("修改新闻中心")
    @PreAuthorize("@ss.hasPermi('index:lcNews:edit')")
    @Log(title = "新闻中心", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LcNews lcNews)
    {
        return toAjax(lcNewsService.updateLcNews(lcNews));
    }

    /**
     * 删除新闻中心
     */
    @ApiOperation("删除新闻中心")
    @PreAuthorize("@ss.hasPermi('index:lcNews:remove')")
    @Log(title = "新闻中心", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(lcNewsService.deleteLcNewsByIds(ids));
    }
}
